require('./index.css');
var _mm=require('util/mm.js');

var header={
	init:function(){
		this.bindEvent();
		this.onLoad();
	},
	onLoad:function(){
		var keyWord=_mm.getUrlParam('keyword');
		if(keyWord){
			$('.search-input').val(keyWord);	
		}
	},
	bindEvent:function(){
		var _this=this;
		$('#serachSumbit').click(function(){
			_this.searchSubmit();
		});
		$('.search-input').keyup(function(e){
			if(e.keyCode==13){
				_this.searchSubmit();
			}
		});
	},
	searchSubmit:function(){
		var keyWord=$.trim($('.search-input').val());
		if(keyWord){
			window.location.href="./list.html?keyword="	+keyWord;
		}else{
			_mm.goHome();
		}
	}
}

header.init();